package com.recharge;

import org.apache.commons.lang3.StringUtils;

import java.io.*;

/**
 * Created by CAOQI on 2017/1/7.
 */
public class TestMain {

    public static void main(String[] args) throws Exception{
        File file = new File("c:/product.txt");
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        String temp = reader . readLine();
        int productId = 1;


        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("c:/product.sql")));
        while(StringUtils.isNotEmpty(temp)){
            Integer supUid=0;
            if (temp.contains("全国")){
                supUid = 5882;
            }else{
                supUid = 6044;
            }


            String status = "0";

            String productName = temp;

            writer.write("INSERT INTO \"TRADE_PRODUCT\" (\"PRODUCT_ID\", \"PRODUCT_NAME\", \"ENABLE\", \"PRIORITY\", \"WEIGHT\") VALUES (" + productId + ", '" + productName + "', '1', '1', '1');");
            writer.newLine();
            writer.write("INSERT INTO \"TRADE_PRODUCT_SUP\" (\"PRODUCT_ID\", \"PRODUCT_NAME\", \"SUP_ID\", \"SUP_NAME\", \"PRIORITY\", \"WEIGHT\", \"STATUS\") VALUES (" + productId + ", '" + productName + "', '" + supUid + "', '" + supUid + "', '1', '1', " + status + ");");
            writer.newLine();
            temp = reader.readLine();
            productId++;
        }


        reader.close();
        writer.flush();
        writer.close();
    }
}